<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Stream Studio</title>
<script src="${cxt!}/files/easyui/jquery.min.js"></script>
<script src="${cxt!}/files/easyui/jquery.easyui.min.js"></script>
<script src="${cxt!}/files/easyui/locale/easyui-lang-zh_CN.js"></script>
<link href="${cxt!}/files/easyui/themes/icon.css" rel="stylesheet" />
<link href="${cxt!}/files/easyui/themes/bootstrap/easyui.css" rel="stylesheet" />

<script src="${cxt!}/files/common/main.js"></script>

<script type="text/javascript" src="${cxt!}/files/My97DatePicker/WdatePicker.js"></script>

<script type="text/javascript">

$(document).ready(function () {
		<%if (!so.isAuthenticated()){%>
			location.href = '/login';
		<%}%>
		$.post("/menu/allMenu", function(data){
			$.each(data, function(i, sm) {
				var menulist = "";
				menulist += '<ul>';
				$.each(sm.children, function(j, o) {
					menulist += '<li><div><a href="#" onclick="ClickMenu($(this));" rel="'
					+ o.url + '" ><span class="nav">' + o.text
					+ '</span></a></div></li> ';
				});
				menulist += '</ul>';

				$('#wnav').accordion('add', {
					title : sm.text,
					content : menulist
				});
			});

			var pp = $('#wnav').accordion('panels');
			var t = pp[0].panel('options').title;
			$('#wnav').accordion('select', t);
		});
	});

	
// 初始化左侧
function InitLeftMenu() {
	hoverMenuItem();
	//alert($('#wnav li a').length);
	$('#wnav li a').on('click', function() {
		var tabTitle = $(this).children('.nav').text();
		var url = $(this).attr("rel");
		addTab(tabTitle, url);
		$('#wnav li div').removeClass("selected");
		$(this).parent().addClass("selected");
	});
}

function ClickMenu(a){
	var tabTitle =a.children('.nav').text();
	var url = a.attr("rel");
	addTab(tabTitle, url);
	$('#wnav li div').removeClass("selected");
	a.parent().addClass("selected");
}

/**
 * 菜单项鼠标Hover
 */
function hoverMenuItem() {
	$(".easyui-accordion").find('a').hover(function() {
		$(this).parent().addClass("hover");
	}, function() {
		$(this).parent().removeClass("hover");
	});
}
function addTab(subtitle, url) {
	if (!$('#tabs').tabs('exists', subtitle)) {
    	$('#tabs').tabs('add', {
        	title: subtitle,
            content: createFrame(url),
            closable: true
            });
         } else {
         	$('#tabs').tabs('select', subtitle);
            $('#mm-tabupdate').click();
		}
	tabClose();
}
 
function createFrame(url) {
	var s = '<iframe scrolling="auto" frameborder="0"  src="' + url + '" style="width:100%;height:100%;"></iframe>';
	return s;
}
 
function tabClose() {
	/*双击关闭TAB选项卡*/
	$(".tabs-inner").dblclick(function () {
		var subtitle = $(this).children(".tabs-closable").text();
		$('#tabs').tabs('close', subtitle);
     })
}
</script>

</head>
<body class="easyui-layout" style="overflow-y: hidden" scroll="no">
     <!--  top -->
     	<div data-options="region:'north'" style="height:26px;padding:2px">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'west',border:false"
				style="width:160px;padding:2px">
				测试环境
			</div>
			<div data-options="region:'east',border:false"
				style="width:160px;padding:2px">
				<% if(so.isAuthenticated()){ %> 您已经登录 <a href="/logout">退出</a> <%
				}else{ %> <a href="javascript:void(0)" onclick="doLogin()">请登录</a>
				<% } %>
			</div>
			<div data-options="region:'center',border:false" style="padding:2px">
			</div>
		</div>
	</div>
     <!--  left -->
     <div id="west" region="west" split="true" title="导航菜单" style="width: 180px; height: 100%">
         <div id="wnav" class="easyui-accordion" fit="true" border="false">
         </div>
     </div>
     <!--  main -->
     <div id="mainPanle" region="center" style="height: 100%">
         <div id="tabs" class="easyui-tabs" fit="true" border="false">
             <div title="欢迎使用" style="padding: 20px; overflow: hidden; color: red;">
             </div>
         </div>
     </div>

	<div id="winLogin" class="easyui-window" title="用户登录"
data-options="modal:true,closed:false,collapsible:false,minimizable:false,maximizable:false,closable:false,closed:true"
		style="width:400px;height:230px">
		<div style="padding:10px 60px 10px 60px">
			<form id="loginForm" action="#" method="post">
				<table cellpadding="5">
					<tr>
						<td width="80px">用户名称:</td>
						<td width="150px"><input class="easyui-textbox" type="text"
							name="username" data-options="required:true"></input></td>
					</tr>
					<tr>
						<td>用户密码:</td>
						<td><input class="easyui-textbox" type="password" name="password"
							data-options="required:true"></input></td>
					</tr>
					<tr>
						<td>验证码:</td>
						<td><input class="easyui-textbox" type="text" name="captcha"
							data-options="required:true"></input><img id="code" src="/img"></td>
					</tr>
				</table>
			</form>
			<div style="text-align:center;padding:5px">
				<a href="javascript:void(0)" class="easyui-linkbutton"
					data-options="iconCls:'icon-tip'" onclick="submitForm()">登录</a> <a
					href="javascript:void(0)" class="easyui-linkbutton"
					data-options="iconCls:'icon-clear'" onclick="clearForm()">清除</a>
			</div>
		</div>
	</div>
	
</body>
</html>